<script>
import { commenLlistRowsFn } from '@/api/category'
import defaultImg from '@/assets/touxiang.png'
export default {
  data() {
    return {
      list: [],
      total: '',
      defaultImg
    }
  },
  methods: {

  },
  mounted() {
    commenLlistRowsFn({ goodsId: this.$route.params.id, limit: 100 }).then(res => {
      // console.log(res);
      const { list, total } = res.data
      this.total = total
      this.list = list

    })


  },

};
</script>

<template>
  <div class="commentTotal">
    <van-nav-bar fixed title="全部评论" left-arrow @click-left="$router.go(-1)" />
    <div class="comment" v-if="total > 0">
      <div class="comment-title">
        <div class="left">商品评价 ({{ total }}条)</div>

      </div>
      <div class="comment-list">
        <div class="comment-item" v-for="item in list" :key="item.comment_id">
          <div class="top">
            <img :src="item.user.avatar_url || defaultImg" alt="">
            <div class="name">{{ item.user.nick_name }} </div>
            <van-rate :size="16" :model-value="item.score / 2" color="#ffd21e" void-icon="star" void-color="#eee" />
          </div>
          <div class="content text-ellipsis-2">
            {{ item.content }}
          </div>
          <div class="time">
            {{ item.create_time }}
          </div>
        </div>
      </div>


    </div>

    <div v-if="total === 0" class="zanwu">
      <img src="../../assets/zanwu.jpg" alt="">
    </div>
  </div>
</template>

<style lang="scss" scoped>
.commentTotal {
  width: 100%;
  padding-top: 46px;
  padding-bottom: 10px;
  height: 100%;
  overflow: hidden;

  ::v-deep .van-icon-arrow-left {
    color: #333;
  }

  .comment {
    padding: 10px;
    overflow: auto;
    height: 100%;

    // .comment-list {
    //   height: 100%;
    //   overflow: auto;
    // }
  }

  .comment-title {
    display: flex;
    justify-content: space-between;

    .right {
      color: #959595;
    }
  }

  .comment-item {
    font-size: 16px;
    line-height: 30px;

    .top {
      height: 30px;
      display: flex;
      align-items: center;
      margin-top: 20px;

      img {
        width: 20px;
        height: 20px;
      }

      .name {
        margin: 0 10px;
      }
    }

    .time {
      color: #999;
    }
  }

  .zanwu {
    width: 100%;
    height: 100%;
    background-color: #f8f8f8;

    img {
      width: 100%;
      height: 100%;
    }
  }

}
</style>